package com.hod.reservgrid.client.model;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Widget;
import com.gwtext.client.data.Record;
import com.gwtext.client.widgets.grid.AbstractSelectionModel;
import com.gwtext.client.widgets.grid.RowSelectionModel;
import com.gwtext.client.widgets.grid.event.RowSelectionListenerAdapter;

public class BedCRUD extends CRUD {
  
  
  	 protected BedGrid gridPanel = null;
  	
      
  	 public BedCRUD() {
  		ds = (GearsDataStore) GWT.create(Bed.class);
  		gridPanel = new BedGrid(false,ds,"");		
  	 }
  		
  	@Override
  	protected void buildPanelSearch() {
  
  		
  	}
  
  	@Override
  	protected AbstractSelectionModel createSelectionModel() {
  		// TODO Auto-generated method stub
  		final RowSelectionModel sm = new RowSelectionModel(true);
          sm.addListener(new RowSelectionListenerAdapter() {
          	public void onRowSelect(RowSelectionModel sm, int rowIndex, Record record) {
                  formPanel.updateDataControls(record);                
              }
          });
          return sm;
  	}
  
  
  	@Override
  	protected Widget formTabs() {
  		// TODO Auto-generated method stub
  		return null;
  	}

	@Override
	public HODForm createFormPanel() {
		// TODO Auto-generated method stub
		if (formPanel==null) {
			formPanel = new BedFormPanel(ds);
		}
		return formPanel;
	}

	public void setIdRoom(Integer idRoom) {
          ((BedFormPanel)formPanel).setIdRoom(idRoom);		
	}

}
